// Sentient actor class
//--------------------------------
#ifndef CREATURE_H
#define CREATURE_H
#include "actor.h"
#include "bcreature.h"
#include "item.h"

class Creature : public Actor, public BIPriority, public BIStats, public BIDerivedStats, public BIOnPush,
                 public BIOnPickup, public BIOnDrop, public BIOnWear, public BIOnWield, public BIOnRemove,
                 public BIOnEat, public BIInventory, public BIOnTick, public BIBlocking, public BIOnAction {
public:

    Creature( int sStr, int sDex, int sInt, int randomlyDistributedPoints = 0 );
    virtual ~Creature() { }

    virtual void Destroy();

    // Returns 0 if the tile can't be seen, and a light value from 0 to 1
    // if it can be
    double CanSeeTile( int x, int y, bool calculateLightValue = true ) const;
    // Returns true if the actor can potentially be seen - need to check the tile
    // it's on too!
    bool   CanSeeActor( const Actor* a ) const;

    // Render the map according to this creatures's perspective
    void GetViewRectangle( int& left, int& right, int& top, int& bottom ) const;
    bool MapToViewCoordinates( int& x, int& y ) const;
    void RenderMap();

    // Inventory
    friend class Item;
    bool IsItemInInventory( const Item* item ) const;
    void GetItemsInInventory(      ItemList& outputList, uint typeMask = 0, uint flammableTypeMask = 0 );
    void GetItemsInInventory( ConstItemList& outputList, uint typeMask = 0, uint flammableTypeMask = 0 ) const;

    int  CountInventoryWeight() const;
    void GetWornItems(    uint type, ItemList& outputList );
    void GetWieldedItems( uint type, ItemList& outputList );

protected:

    virtual bool Priority( int* priority ) const;
    virtual bool Blocking( bool* blocking, bool* losBlocking, uint* pushType ) const;
    virtual bool Stats( int* hpMax, int* mpMax, int* sStr, int* sDex, int* sInt,
                        int* ac, int* magicRes, int* fireRes ) const;
    virtual bool DerivedStats( double* hpRegen, double* mpRegen, int* weightMax ) const;
    virtual bool Inventory( ItemList* list );
    virtual bool OnPush( Actor* target, bool reverse, bool* pushed );
    virtual bool OnPickup( Item** item, bool* pickedUp );
    virtual bool OnDrop( Item** item, bool* dropped );
    virtual bool OnWear( Item** item, bool* worn );
    virtual bool OnWield( Item** item, bool* wielded );
    virtual bool OnRemove( Item** item, bool* removed );
    virtual bool OnEat( Item** item, bool* eaten );
    virtual bool OnTick();

    int _sStr;
    int _sDex;
    int _sInt;

    int _hp;
    int _mp;
    double _hpRegen;
    double _mpRegen;

private:

    void AddItem(    Item* item );
    void RemoveItem( Item* item );

    ItemSet _items;

};

#endif
